﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TradingResult.ascx.cs"
    Inherits="TCKQKL.FrontEnd.Web.Controls.TradingResult" %>
<link href="../styles/data.css" rel="stylesheet" type="text/css" />
<%@ Import Namespace="TCKQKL.FrontEnd.DataModel" %>
<%@ Import Namespace="TCKQKL.FrontEnd.Config" %>
<table class="result" style="border: none;">
    <% if (tradingResults != null)
           if (tradingResults.Count > 0)
           {%>
    <!-- Main orders header -->
    <tr>
        <td class="OrderAlertMessageStyle" colspan="9">
            <img alt="trading result" src="../Images/transactions.gif" />KẾT QUẢ GIAO DỊCH
        </td>
    </tr>
    <tr>
        <th class="InnerHeading">
            Order ID
        </th>
        <th class="InnerHeading">
            Side
        </th>
        <th class="InnerHeading">
            Type
        </th>
        <th class="InnerHeading">
            Class
        </th>
        <th class="InnerHeading">
            Status
        </th>
        <th class="InnerHeading">
            Date
        </th>
        <th class="InnerHeading">
            Symbol
        </th>
        <th class="InnerHeading">
            Quantity
        </th>
        <th class="InnerHeading">
            Price
        </th>
    </tr>
    <%for (int i = 0; i < tradingResults.Count; i++)
      { %>
    <!-- Main orders detail -->
    <tr class="Master">
        <td>
            <%=tradingResults[i].RootOrder.orderID%>
        </td>
        <td>
            <%=tradingResults[i].RootOrder.OrderSide%>
        </td>
        <td>
            <%=tradingResults[i].RootOrder.orderType%>
        </td>
        <td>
            <%=tradingResults[i].RootOrder.OrderClass%>
        </td>
        <td>
            <%=tradingResults[i].RootOrder.orderStatus%>
        </td>
        <td>
            <%=tradingResults[i].RootOrder.openDate.ToString("dd/MM/yyyy")%>
        </td>
        <td>
            <%=tradingResults[i].RootOrder.symbol%>
        </td>
        <td style="text-align: right">
            <%=String.Format("{0:0,0}", tradingResults[i].RootOrder.quantity)%>
        </td>
        <td style="text-align: right">
            <%=String.Format("{0:0,0}",tradingResults[i].RootOrder.price)%>
        </td>
    </tr>
    <%if (tradingResults[i].RelatedOrders != null)
          if (tradingResults[i].RelatedOrders.Count > 0)
          {%>
    <tr class="even">
        <td colspan="9">
            <table class="trace">
                <!-- Result header -->
                <tr>
                    <td colspan="9">
                        Các lệnh liên quan
                    </td>
                </tr>
                <tr>
                    <th class="InnerHeading">
                        Order ID
                    </th>
                    <th class="InnerHeading">
                        Side
                    </th>
                    <th class="InnerHeading">
                        Type
                    </th>
                    <th class="InnerHeading">
                        Class
                    </th>
                    <th class="InnerHeading">
                        Status
                    </th>
                    <th class="InnerHeading">
                        Date
                    </th>
                    <th class="InnerHeading">
                        Symbol
                    </th>
                    <th class="InnerHeading">
                        Quantity
                    </th>
                    <th class="InnerHeading">
                        Price
                    </th>
                </tr>
                <!-- Result details-->
                <%for (int k = 0; k < tradingResults[i].RelatedOrders.Count; k++)
                  { %>
                <tr>
                    <td class="InnerData">
                        <%=tradingResults[i].RelatedOrders[k].orderID%>
                    </td>
                    <td class="InnerData">
                        <%=tradingResults[i].RelatedOrders[k].OrderSide%>
                    </td>
                    <td class="InnerData">
                        <%=tradingResults[i].RelatedOrders[k].orderType%>
                    </td>
                    <td class="InnerData">
                        <%=tradingResults[i].RelatedOrders[k].OrderClass%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=tradingResults[i].RelatedOrders[k].orderStatus%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=tradingResults[i].RelatedOrders[k].openDate.ToString("dd/MM/yyyy")%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=tradingResults[i].RelatedOrders[k].symbol%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=String.Format("{0:0,0}",tradingResults[i].RelatedOrders[k].quantity)%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=String.Format("{0:0,0}",tradingResults[i].RelatedOrders[k].price)%>
                    </td>
                </tr>
                <%}%>
            </table>
        </td>
    </tr>
    <%}%>
    <%if (tradingResults[i].DetailMatched != null)
          if (tradingResults[i].DetailMatched.Count > 0)
          {%>
    <tr class="even">
        <td colspan="9">
            <table class="trace">
                <!-- Result header -->
                <tr>
                    <td colspan="8">
                        Chi tiết khớp lệnh
                    </td>
                </tr>
                <tr>
                    <th class="InnerHeading">
                        Order ID
                    </th>
                    <th class="InnerHeading">
                        Date
                    </th>
                    <th class="InnerHeading">
                        Type
                    </th>
                    <th class="InnerHeading">
                        Symbol
                    </th>
                    <th class="InnerHeading">
                        Quantity
                    </th>
                    <th class="InnerHeading">
                        Price
                    </th>
                    <th class="InnerHeading">
                        Fee
                    </th>
                    <th class="InnerHeading">
                        Confirm No
                    </th>
                </tr>
                <!-- Result details-->
                <%for (int j = 0; j < tradingResults[i].DetailMatched.Count; j++)
                  { %>
                <tr>
                    <td class="InnerData">
                        <%=tradingResults[i].DetailMatched[j].orderID%>
                    </td>
                    <td class="InnerData">
                        <%=tradingResults[i].DetailMatched[j].transDate.ToString("dd/MM/yyyy")%>
                    </td>
                    <td class="InnerData">
                        <%=tradingResults[i].DetailMatched[j].TransType%>
                    </td>
                    <td class="InnerData">
                        <%=tradingResults[i].DetailMatched[j].stockCode%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=String.Format("{0:0,0}",tradingResults[i].DetailMatched[j].stockQtty)%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=String.Format("{0:0,0}",tradingResults[i].DetailMatched[j].price)%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=String.Format("{0:0,0}",tradingResults[i].DetailMatched[j].feeAmount)%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=tradingResults[i].DetailMatched[j].confirmNo%>
                    </td>
                </tr>
                <%}%>
                <tr class="subtotal">
                    <td class="InnerData" colspan="2">
                        Lệnh khớp</td>
                    <td class="InnerData">
                        <%=tradingResults[i].Side%>
                    </td>
                    <td class="InnerData">
                        <%=tradingResults[i].Symbol%>
                    </td>
                    <td class="InnerData">
                        <%=String.Format("{0:0,0}", tradingResults[i].SubQtty)%>
                    </td>
                    <td class="InnerData">
                        <%=(tradingResults[i].SubQtty!=0)?String.Format("{0:0,0}", (tradingResults[i].SubValue / tradingResults[i].SubQtty)):String.Empty%>
                    </td>
                    <td class="InnerData">
                        <%=String.Format("{0:0,0}", tradingResults[i].FeeAmount)%>
                    </td>
                    <td class="InnerData">
                        &nbsp;
                    </td>
                    <td class="InnerData">
                        <%=String.Format("{0:0,0}", tradingResults[i].SubValue)%>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <%}%>
    <%}%>
    <%}%>
    <tr>
        <td colspan="9" style="margin: 0px; padding: 0px;">
        </td>
    </tr>
</table>
